
#include			"ClientManager.h"

ClientManager::~ClientManager()
{
	clear();
}

std::map<unsigned int, IClient *>	ClientManager::getMap() const
{
	return _clients;
}

IClient				*ClientManager::operator[](unsigned int id)
{
	if (_clients.find(id) != _clients.end())
		return _clients[id];
	return NULL;
}

void				ClientManager::clear()
{
	for (std::map<unsigned int, IClient *>::iterator it = _clients.begin(); it != _clients.end(); ++it)
		delete it->second;
}

void				ClientManager::add(unsigned int id, IClient *client)
{
	_clients[id] = client;
}

void				ClientManager::remove(unsigned int id)
{
	_clients.erase(id);
}

bool				ClientManager::find(unsigned int id)
{
	if (_clients.find(id) != _clients.end())
		return true;
	return false;
}